<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2019/6/17
 * Time: 10:36
 */
namespace app\admin\controller;
use think\Db;
class Teamwork extends Base
{
    public function index(){
        if(request()->isAjax ()){
            extract (input ());
            $map = [];
            if(session ('area')){
                $map['user_area'] = ['in',session('area')];
            }
            if(isset($key)&&$key!="")
            {
                $map['user_username|t_phone'] = ['like',"%" . $key . "%"];
            }
            $Nowpage = input('page') ? input('page'):1;
            $limits = input("limit")?input("limit"):10;// 获取总条数;
            $count = Db::name('teamwork t')
                ->join('u_user u','u.user_id = t.t_user_id','left')
                ->where($map)
                ->count();
            $lists =  Db::name('teamwork t')
                ->join('u_user u','u.user_id = t.t_user_id','left')
                ->where($map)
                ->page($Nowpage,$limits)
                ->order('t_add_time desc')
                ->select ();
            if(!empty($lists)){
                foreach ($lists as $key=>$vo){
                    $lists[$key]['t_images'] = explode (',',$vo['t_images']);
                }
            }
            return json(['code'=>220,'msg'=>'','count'=>$count,'data'=>$lists]);
        }
        return $this->fetch ('teamwork/index');
    }
}